import 'package:flutter/material.dart';
import 'package:whale/helper/utils/util.dart';

import '../../../../helper/component/component.dart';
import 'index.dart';
import 'widgets/widgets.dart';

class MeansDetailPage extends GetView<MeansDetailController> {
  const MeansDetailPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    var state = controller.state;
    return GetBuilder<MeansDetailController>(
      builder: (_) {
        return Scaffold(
          appBar: detailAppBar(
            context,
            title: '详情',
          ),
          body: SafeArea(
            child: NestedScrollView(
              controller: state.sc,
              headerSliverBuilder: (context, innerBoxIsScrolled) {
                return [
                  const SliverToBoxAdapter(
                    child: ReportHeaderView(),
                  ),
                  SliverPersistentHeader(
                    pinned: true,
                    floating: true,
                    delegate: TPSliverPersistentHeaderDelegate(
                        floatColor: Colors.white,
                        builder: (off) {
                          return SizedBox(
                            height: 40.r,
                            // color: Colors.white,
                            child: TPTabBar(
                              controller: state.tabCtrl,
                              selectedStyle: TextStyle(
                                color: ColorsUtil.theme,
                                fontSize: 14.sp,
                              ),
                              unSelectedStyle: TextStyle(
                                color: ColorsUtil.content,
                                fontSize: 14.sp,
                              ),
                            ),
                          );
                        },
                        max: 40.r,
                        min: 40.r),
                  ),
                ];
              },
              body: Padding(
                padding: EdgeInsets.only(bottom: 50.r),
                child: const MeansDetailContentView(),
              ),
            ),
          ),
          floatingActionButtonLocation:
              FloatingActionButtonLocation.centerDocked,
          floatingActionButton: Container(
            constraints: BoxConstraints(minHeight: 60.r),
            height: 60.r,
            color: Colors.white,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: [
                MenuItemView(
                  icon:
                      loadImage(url: 'download.png'.imgPathMeans, width: 23.r),
                  spacing: 5.r,
                  title: Text(
                    '下载',
                    style: TextStyle(color: ColorsUtil.title, fontSize: 11.r),
                  ),
                ),
                MenuItemView(
                  icon: loadImage(url: 'note.png'.imgPathMeans, width: 23.r),
                  spacing: 5,
                  title: Text('批注',
                      style:
                          TextStyle(color: ColorsUtil.title, fontSize: 11.r)),
                  onTap: () {
                    if (state.mod?.problemList != null) {
                      showTagsDialog(state.mod!.problemList!);
                    }
                  },
                ),
                MenuItemView(
                  icon: loadImage(url: 'setup.png'.imgPathMeans, width: 23.r),
                  spacing: 5,
                  title: Text('设置',
                      style:
                          TextStyle(color: ColorsUtil.title, fontSize: 11.r)),
                )
              ],
            ),
          ),
        );
      },
    );
  }
}
